clove/pkviewer
web/src/routes/manage/[systemId]/+page.svelte
back to web/src/routes/manage/[systemId]
<!-- web/src/routes/manage/[systemId]/+page.svelte -->
<script lang="ts">
import { site } from "$lib/config.ts";
import Icon from "$lib/components/Icon.svelte";
import BadgeOffers from "$lib/components/manage/BadgeOffers.svelte";
import Note from "$lib/components/manage/Note.svelte";
import PageHeader from "$lib/components/manage/PageHeader.svelte";
import PublicUrl from "$lib/components/manage/PublicUrl.svelte";
import Section from "$lib/components/manage/Section.svelte";
let { data } = $props();
const system = $derived(data.system);
const publicUrl = $derived(`${site.publicOrigin}${system.publicPath}`);
const idUrl = $derived(`${site.publicOrigin}/s/${system.pkSystemHid}`);
function formatAge(ms: number): string {
const minutes = Math.round(ms / 60_000);
if (minutes < 1) return "less than a minute";
if (minutes < 60) return `${minutes} minute${minutes === 1 ? "" : "s"}`;
const hours = Math.round(minutes / 60);
if (hours < 24) return `${hours} hour${hours === 1 ? "" : "s"}`;
return `${Math.round(hours / 24)} days`;
}
</script>
<svelte:head>
<title>Overview · Manage · pkviewer</title>
</svelte:head>
<PageHeader title="Overview" description="Where this system lives on the web, and what visitors see." />
{#if !system.reachable}
<Note icon="exclamation-triangle" tone="warn" role="status">
PluralKit could not be reached, so some details may be out of date. Your
settings are unaffected and still save normally.
</Note>
{/if}
<Section title="Public page" description="The link to share.">
{#snippet actions()}
<a class="btn" href="/manage/{system.systemId}/address">
<Icon name="pencil-square" />
{system.slug ? "Change address" : "Choose an address"}
</a>
{/snippet}
{#if system.slug}
<PublicUrl
url={publicUrl}
secondary={{
url: idUrl,
note: "Its PluralKit ID address also works and always will:",
}}
/>
{:else}
<PublicUrl url={publicUrl} label="Current address" />
<Note icon="info-circle">
This system is public already. It has no chosen address yet, so it
uses its PluralKit ID. Choosing one makes the link friendlier to
share, and the ID address keeps working either way.
</Note>
{/if}
</Section>
<Section title="What visitors see" description="Taken from PluralKit's public information.">
<dl class="mg-defs">
<div class="mg-def">
<dt>Name</dt>
<dd>{system.name ?? "Not set"}</dd>
</div>
<div class="mg-def">
<dt>Members listed</dt>
<dd>
{system.memberCount === null
? "Unknown"
: `${system.memberCount} public ${system.memberCount === 1 ? "member" : "members"}`}
</dd>
</div>
<div class="mg-def">
<dt>Description</dt>
<dd>
{system.description
? `${system.description.slice(0, 160)}${system.description.length > 160 ? "…" : ""}`
: "Not set"}
</dd>
</div>
</dl>
</Section>
{#if data.offers}
<BadgeOffers systemId={system.systemId} badges={data.offers} />
{/if}
<Section
title="Data freshness"
description="pkviewer keeps a copy of PluralKit's public data so pages stay fast, and stay up if PluralKit is briefly unavailable."
>
<Note icon="clock-history">
{system.snapshotAgeMs === null
? "No cached copy yet."
: `Last refreshed ${formatAge(system.snapshotAgeMs)} ago.`}
</Note>
</Section>